var app = getApp()
var QQMapWX = require('../../utils/qqmap-wx-jssdk.js');
Page({
  data: {
    objarr: [],
    height:0,
    width:0,
    codeimg:''
  },
  onLoad: function (options) {
    var that = this;
    
    wx.getSystemInfo({
      success: function (res) {
        console.log(res);
        that.setData({
           width: res.windowWidth,
           height:res.windowHeight })
      }
    })
    if (!app.check_empty(options.id)) {
      app.ajax("create_code", {wish_id:options.id}, (data, err) => {
        if (data.data.url){
          this.setData({
            codeimg: data.data.url
          })
        }
      })
    }
    
  },
 
  imageLoad(e) {
    let that = this
    this.setData({
      imgh: app.fixImgW(e, that.data.width),
    })
  },

  save() {
    let that = this
    wx.downloadFile({
      url: this.data.codeimg,
      success: function (res) {
        console.log(res)
        wx.saveImageToPhotosAlbum({
          filePath: res.tempFilePath,
          success: function (res) {
            wx.showToast({
              title: '保存成功',
            })
          },
          fail: function (res) {
            console.log(res)
            console.log('fail')
          }
        })
      },
      fail: function () {
        console.log('fail')
      }
    })
  }
 
  
});